package ren.colorful.learnJava.nio;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.channels.FileChannel;

public class UserFileChinnel {
	public static void main(String[] args) throws IOException {
		RandomAccessFile fromFile = new RandomAccessFile("a.txt", "rw");
		FileChannel fromChannel = fromFile.getChannel();
		
		RandomAccessFile toFile = new RandomAccessFile("toFile.txt", "rw");
		FileChannel toChannel = toFile.getChannel();
		
		long position = 0;
		long count = fromChannel.size();
		toChannel.transferFrom(fromChannel, position, count);
		
		fromChannel.transferTo(position, count, toChannel);
	}
}
